<?

class filter
{
	public static function white( $value, $list )
	{
		return in_array($value, $list) ? $value : array_shift($list);
	}

	public static function white_keys( $values, $filter )
	{
		foreach ( $values as $key => $val ) if (in_array($key, $filter) ) $list[$key] = $val;
		return $list;
	}

	public static function range( $val, $min, $max )
	{
		if ( $val < $min ) return $min;
		if ( $val > $max ) return $max;

		return $val;
	}
}